This specifies a color whose red component is 1.0 or 100% of full intensity and the green component is 0.5 or 50% of full intensity. Although the blue, filter and transmit components are not explicitly specified, they exist and are set to their default values of 0. The component keywords may be given in any order and if any component is unspecified its value defaults to zero.
Where IDENTIFIER is the name of the identifier up to 40 characters long and COLOR_VECTOR or COLOR_KEYWORDS are any valid color specifications as described in the two previous sections of this document. Here are some examples...
As the LightGray example shows, you do not need any color keywords when creating color expressions based on previously declared colors. The last example shows you may use a color identifier with the keyword style syntax. WARNING: Make sure the identifier is first before any other component keywords.
Like floats and vectors, you may re-define colors throughout a scene but the need to do so is rare.
You may use the dot operator to extract a single component from a color. Suppose the identifier "Shade" was previously defined as a color. Then Shade.red is the float value of the red component of Shade. Similarly Shade.green Shade.blue Shade.filter and Shade.transmit extract the float value of the other color components.
When using filter transparency, the colors which come through are multiplied by the primary color components. For example if grey light such as rgb<0.9,0.9,0.9> passes through a filter such as rgbf<1.0,0.5,0.0.1.0> the result is rgb<0.9,0.45,0.0> with the red let through 100%, the green cut in half from 0.9 to 0.45 and the blue totally blocked. Often users mistakenly specify a clear object by
but this has implied red, green and blue values of zero. You've just specified a totally black filter so no light passes through. The correct way is either:
or:
In the 2nd example it doesn't matter what the rgb values are. All of the light passes through untouched.
Another pitfall is the use of color identifiers and expressions with color keywords. For example...
this substitutes whatever was the red component of My_Color with a red component of 0.5 however...
adds 0.5 to the red component of My_Color and even less obvious...
this cuts the red component in half as you would expect but it also multiplies the green, blue, filter and transmit components by zero! The part of the expression after the multiply operator evaluates to rgbft<0.5,0,0,0,0> as a full 5 component color.
The following example results in no change to My_Color.
that is because the identifier fully overwrites the previous value. When using identifiers with color keywords, the identifier should be first.
One final issue, some POV-Ray syntax allows full color specifications but only uses the rgb part. In these cases it is legal to use a float where a color is needed. For example:
The ambient keyword expects a color so the value 1 is promoted to <1,1,1,1,1> which is no problem. However
is legal but it may or may not be what you intended. The 0.4 is promoted to <0.4,0.4,0.4,0.4,0.4> with the filter and transmit set to 0.4 as well. It is more likely you wanted...
in which case a 3 component vector is expected. Therefore the 0.4 is promoted to <0.4,0.4,0.4,0.0,0.0> with default zero for filter and transmit.
"Here" "There" "myfile.gif" "textures.inc"
Where IDENTIFIER is the name of the identifier up to 40 characters long and STRING is a string literal, string identifier or function which returns a string value. Here are some examples...
As the last example shows, you can re-declare a string identifier and may use previously declared values in that re-declaration.
The built-in float identifier pi is obviously useful in math expressions involving circles.
The built-in float identifiers on off yes no true false are designed for use as boolean constants.
The built-in vector identifiers x y and z provide much greater readability for your scene files when used in vector expressions. For example....
An expression like 5*x evaluates to 5*<1,0,0> or <5,0,0>.
Similarly u and v may be used in 2D vectors. When using 4D vectors you should use x y z and t and POV-Ray will promote x y and z to 4D when used where 4D is required.
Other INI options and switches may be used to animate scenes by automatically looping through the rendering of frames using various values for clock. By default, the clock value is 0 for the initial frame and 1 for the final frame. All other frames are interpolated between these values. For example if your object is supposed to rotate one full turn over the course of the animation, you could specify rotate 360*clock*y Then as clock runs from 0 to 1, the object rotates about the y-axis from 0 to 360 degrees.
Although the value of clock will change from frame-to-frame, it will never change throughout the parsing of a scene.
See "Animation Options" for more details.
The INI option or switch only affects the initial setting. Unlike other built-in identifiers, you may change the value of version throughout a scene file. You do not use #declare to change it. The #version language directive is used to change modes. Such changes may occur several times within scene files.
Function calls consist of a keyword which specifies the name of the function followed by a parameter list enclosed in parentheses. Parameters are separated by commas. For example:
Functions evaluate to values that are floats, vectors or strings and may be used in expressions or statements anywhere that literals or identifiers of that type may be used.
abs(A): Absolute value of A. If A is negative, returns -A otherwise returns A.
acos(A): Arc-cosine of A. Returns the angle, measured in radians, whose cosine is A.
asin(A): Arc-sine of A. Returns the angle, measured in radians, whose sine is A.
atan2(A,B): Arc-tangent of (A/B). Returns the angle, measured in radians, whose tangent is (A/B). Returns appropriate value even if B is zero. Use atan2(A,1) to compute usual atan(A) function.
ceil(A): Ceiling of A. Returns the smallest integer greater than A. Rounds up to the next higher integer.
cos(A): Cosine of A. Returns the cosine of the angle A, where A is measured in radians.
degrees(A): Convert radians to degrees. Returns the angle measured in degrees whose value in radians is A. Formula is degrees=A/pi*180.0.
div(A,B): Integer division. The integer part of (A/B).
exp(A): Exponential of A. Returns the value of e raised to the A power where e is the non-repeating value approximately equal to 2.71828182846 the base of natural logarithms.
floor(A): Floor of A. Returns the largest integer less than A. Rounds down to the next lower integer.
int(A): Integer part of A. Returns the truncated integer part of A. Rounds towards zero.
log(A): Natural logarithm of A. Returns the natural logarithm base e of the value A where e is the non-repeating value approximately equal to 2.71828182846.
max(A,B): Maximum of A and B. Returns A if A larger than B. Otherwise returns B.
min(A,B): Minimum of A and B. Returns A if A smaller than B. Otherwise returns B.
mod(A,B): Value of A modulo A. Returns the remainder after the integer division of A/B. Formula is mod=((A/B)-int(A/B))*B.
pow(A,B): Exponentiation. Returns the value of A raised to the power B.
radians(A): Convert degrees to radians. Returns the angle measured in radians whose value in degrees is A. Formula is radians=A*pi/180.0.
sin(A): Sine of A. Returns the sine of the angle A, where A is measured in radians.
sqrt(A): Square root of A. Returns the value whose square is A.
tan(A): Tangent of A. Returns the tangent of the angle A, where A is measured in radians.
vaxis_rotate(V1,V2,A): Rotate V1 about V2 by A. Given the x,y,z coordinates of a point in space designated by the vector V1, rotate that point about an arbitrary axis defined by the vector V2. Rotate it through an angle specified in degrees by the float value A. The result is a vector containing the new x,y,z coordinates of the point.
vcross(V1,V2): Cross product of V1 and V2. Returns a vector that is the vector cross product of the two vectors. The resulting vector is perpendicular to the two original vectors and its length is proportional to the angle between them. See the animated demo scene VECT2.POV for an illustration.
vdot(V1,V2): Dot product of V1 and V2. Returns a float value that is the dot product (sometimes called scaler product of V1 with V2. Formula is vdot=V1.x*V2.x + V1.y*V2.y + V1.z*V2.z. See the animated demo scene VECT2.POV for an illustration.
vlength(V1): Length of V1. Returns a float value that is the length of vector V1. Can be used to compute the distance between two points. Dist=vlength(V2-V1). Formula is vlength=sqrt(vdot(V1,V1)).
vnormalize(V1): Normalize vector V1. Returns a unit length vector that is the same direction as V1. Formula is vnormalize=V1/vlength(V1).
vrotate(V1,V2): Rotate V1 about origin by V2. Given the x,y,z coordinates of a point in space designated by the vector V1, rotate that point about the origin by an amount specified by the vector V2. Rotate it about the x-axis by an angle specified in degrees by the float value V2.x. Similarly V2.y and V2.z specify the amount to rotate in degrees about the y-axis and z-axis. The result is a vector containing the new x,y,z coordinates of the point.